package com.lp.business.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.iframework.commons.domain.enums.RecordStatus;
import org.iframework.commons.util.fast.V;
import org.iframework.support.spring.hibernate.dao.BaseHibernateDaoSupport;
import org.iframework.support.spring.hibernate.service.BaseServiceSupport;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.lp.business.dao.IndustryDao;
import com.lp.business.model.Industry;
import com.lp.business.service.IndustryService;

/**
 * 行业分类信息模型服务接口实现类<br>
 * 说明：支持方法查阅实现接口
 * 
 * @author lp
 * @email lp@qq.com
 * @date 2018-08-23 10:38:18
 */
@Service("industryService")
public class IndustryServiceImpl extends BaseServiceSupport<Industry, String> implements IndustryService {
	@Resource(name = "industryDao")
	public void setBaseHibernateDaoSupport(@Qualifier("industryDaoImpl") BaseHibernateDaoSupport<Industry, String> baseHibernateDaoSupport) {
		this.baseHibernateDaoSupport = baseHibernateDaoSupport;
	}

	@Override
	public Industry findByName(String industryName) {
		if(V.isEmpty(industryName)) {
			return null;
		}
		Industry model = new Industry();
		model.setStatus(RecordStatus.AVAILABLE);
		model.setName(industryName);
		List<Industry> models = this.findByModel(model, null, null);
		return V.isNotEmpty(models)?models.get(0):null;
	}

	@Override
	public List<Map<String, Object>> findIndustrys(Industry model) {
		return ((IndustryDao)this.baseHibernateDaoSupport).findIndustrys(model);
	}
	
}